package vn.edu.hut.soict.translate.dictionary;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Dictionary<K, V> {
	private Map<K, List<V>> entryList;

	protected Dictionary() {
		entryList = new HashMap<K, List<V>>();
	}

	protected void addEntry(K entry, V content) {
		if (entryList.containsKey(entry)) {
			entryList.get(entry).add(content);
		}
		else {
			List<V> contentList = new ArrayList<V>();
			entryList.put(entry, contentList);
			contentList.add(content);
		}
	}

	protected List<V> lookUp(K entry) {
		if (entryList.containsKey(entry)) {
			return entryList.get(entry);
		}
		else {
			System.err.println("Entry not found in dictionary: " + entry);
			return null;
		}
	}
}